package main

import (
	"fmt"
	"sync"
)

var num int
var mtx sync.Mutex
var wg sync.WaitGroup

func main() {
	for i := 0; i < 1000; i++ {
		wg.Add(1)
		go func() {
			defer wg.Done()
			mtx.Lock()
			num += 1
			mtx.Unlock()
		}()
	}
	wg.Wait()
	fmt.Println(num)
}
